<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/vue/2.6.14/vue.js" type="application/javascript"></script>
</head>
<body>
  <div id="app">
    <hello></hello>
    <world></world>
  </div>
</body>
<script>
   // 给每一个组件添加一个方法
  Vue.mixin({
    created(){
      console.log('混入的created')
    },
    data(){
      return{
        username:'zs',
        age:20
      }
    },
    methods:{
      say(){
        console.log('hi')
      }
    }
  })
  const obj ={
    data(){
      return{
        sex: 0
      }
    }
  }
  Vue.component('hello',{
    template:`
      <div>hello-{{username}}-{{age}}<button @click="say">say</button></div>
    `
  })
  Vue.component('world',{
    data(){
      return{
        username:'ls'
      }
    },
    template:`
      <div>world-{{username}}-{{age}}<button @click="say">say</button></div>
    `,
    created(){
      // 混入钩子函数依然会执行没有被覆盖
      console.log('world的created')
    }
  })
  let vm = new Vue({
    el: '#app'
  })
</script>
</html>
